#!/usr/bin python3
# -*- coding:UTF-8 -*-
# Author: nigo
import pandas as pd
import plotly.graph_objects as go
# 数据
df = pd.DataFrame([
    ["2020", 168308 , 65597480 ],
    ["2019", 97303 , 44893158 ],
    ["2018", 46606 , 25674345 ],
    ["2017", 20484 , 14412037 ]],columns= ["年度","总用户数","销售额"])
df = df.sort_values(by='年度') # 按年度排序（升序
# 轨迹（线）
line1 = go.Scatter(x=df['年度'],y=df['总用户数'],mode='lines+markers',name='总用户数')
line2 = go.Scatter(x=df['年度'],y=df['销售额'],mode='lines+markers',name='销售额',yaxis='y2')
# 画布
fig = go.Figure([line1,line2])
# 修改样式
fig.update_layout(title='用户增长与销售额对比分析',
                 yaxis_title='总用户数(万人)',
                 yaxis2=dict(title='销售额(万元)',overlaying='y',side='right'),
                 xaxis_title = '年度'
                 )
# 显示画布
fig.show()
